<?php

/**
 * WeEngine System
 *
 * (c) We7Team 2021 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

namespace App\Http\Middleware;

use Illuminate\Auth\AuthenticationException;

class Authenticate
{
    public function handle($request, \Closure $next, ...$guards)
    {
        if ((int)$request->session()->get('user_id') <= 0) {
            throw new AuthenticationException(
                'Unauthenticated.',
                $guards,
                route('login')
            );
        }
        return $next($request);
    }
}
